#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author   : Moty
# @Time     : 2024/1/22 0:10
# @File     : jt808_8108.py
# @Project  : jt808
def parse_terminal_upgrade(body):
    # 解析0x8108 下发终端升级包
    data = {
        # 消息体为空
        "升级类型": body[0:2],
        "制造商ID": body[2:12],
        "终端固件版本号长度": body[12:14],
        "终端固件版本号": body[12:12 + int(body[12:14], 16)],
        "升级数据包长度": body[12 + int(body[12:14], 16):12 + int(body[12:14], 16) + 4],
        "升级数据包": body[12 + int(body[12:14], 16) + 4:],
    }
    formatted_data = ""
    for key, value in data.items():
        formatted_data += f"{key}: {value}\n"
    return formatted_data


__all__ = ['parse_terminal_upgrade']
